package com.chinacoal.microservice.controller;

import com.chinacoal.microservice.RoomManagementClient;
import com.chinacoal.microservice.pojo.CcmsSmartleasingDeviceChange;
import com.chinacoal.microservice.pojo.CcmsSmartleasingRoom;
import com.chinacoal.microservice.service.RoomManagementService;
import com.chinacoal.microservice.util.QueryCriteria;
import com.chinacoal.microservice.util.Result;
import com.chinacoal.microservice.util.UserLoginToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 房源管理-房间管理-后端控制类
 * @date 2020-11-12 10：54
 */
@RestController
public class RoomManagementController implements RoomManagementClient {

    @Autowired
    private RoomManagementService roomManagementService;

    /**
     * @Description: 查询所有的房间信息（带分页）
     * @author zhuliang
     * @date 2020/11/12 10:55
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingRoom>> getListByPage(QueryCriteria queryCriteria, String token) {
        return roomManagementService.getListByPage(queryCriteria, token);
    }

    /**
     * @Description: 根据房间id查询房间信息
     * @author zhuliang
     * @date 2020/11/12 11:26
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingRoom> getRoomById(String pkRoomId, String token) {
        return roomManagementService.getRoomById(pkRoomId, token);
    }

    /**
     * @Description: 添加房间信息
     * @author zhuliang
     * @date 2020/11/12 11:36
     */
    @Override
    @UserLoginToken
    public Result addRoom(String token, CcmsSmartleasingRoom room) {
        return roomManagementService.addRoom(token, room);
    }

    /**
     * @Description: 修改房间信息
     * @author zhuliang
     * @date 2020/11/12 11:42
     */
    @Override
    @UserLoginToken
    public Result updateRoom(String token, CcmsSmartleasingRoom room) {
        return roomManagementService.updateRoom(token, room);
    }

    /**
     * @Description: 根据房间id批量删除房间信息
     * @author zhuliang
     * @date 2020/11/12 11:46
     */
    @Override
    @UserLoginToken
    public Result deleteRoom(String token, String deleteId) {
        return roomManagementService.deleteRoom(token, deleteId);
    }

    /**
     * @Description: 条件查询（带分页）
     * @author zhuliang
     * @date 2020/11/12 17:36
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingRoom>> queryRoomManagement(QueryCriteria queryCriteria, String token) {
        return roomManagementService.queryRoomManagement(queryCriteria, token);
    }

    /**
     * @Description: 修改出租信息
     * @author zhuliang
     * @date 2020/12/2 15:03
     */
    @Override
    @UserLoginToken
    public Result updateByRent(CcmsSmartleasingRoom room, String token) {
        return roomManagementService.updateByRent(room, token);
    }

    /**
     * @description
     * @author leo
     * @date 2022-12-18 21:14
     */
    @Override
    @UserLoginToken
    public Result addDeviceChange(String token, CcmsSmartleasingDeviceChange deviceChange) {
        return roomManagementService.addDeviceChange(token,deviceChange);
    }

    /**
     * @description
     * @author leo
     * @date 2022-12-19 18:10
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingDeviceChange>> getDeviceChangesByRoomId_CurrentMonth(String pkRoomId, String bCurrentMonth,String token) {
        return roomManagementService.getDeviceChangesByRoomId_CurrentMonth(pkRoomId, bCurrentMonth,token);
    }
}
